var thisPageNum = 2;
var thisWork = 1;
var brak=0;
function getNextP(){
if(thisWork == 1){
    thisWork = 0;
            $("#upBlock").css('display','block');
            $.get(""+thisPageNum+"/true/", function(data){
                if(data==''){
                    brak=1;
                }
            $("#upBlock").css('display','none');
            //$("#LoadDiv").html($("#LoadDiv").html()+" "+data);
            $(".shop_main").append(data);
            thisPageNum = thisPageNum + 1;
            thisWork = 1;
            });
       }
}

$(document).ready(function(){

var scrH = $(window).height();
var scrHP = $("#container").height();
var windHeight = $(".main_container").height();
var bodyH = $('body').height();

//    if(windHeight>900&&brak==0){
//        getNextP();
//    }
$(window).scroll(function(){
    var scro = $(this).scrollTop();

    var scrHP = $(".main_container").height();
    var scrH2 = 0;
    scrH2 = scrH + scro;
    var leftH = scrHP - scrH2;

    if(leftH < 5&&brak==0){
         getNextP();
//        scrollerUp();
        }
    if ($(this).scrollTop() > 100) {
        $('.scrollto').fadeIn('slow');
    } else {
        $('.scrollto').fadeOut('slow');
    }

    });



    $(".scrollto").hide();
        $('.scrollto').click(function () {
            $('body,html').animate({
                scrollTop: 0
            }, 1200);
            return false;
        });


});
